<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用父类构造初始属性</title>
</head>
<body>
    <script>
        // 在父类中构造初始值
        function User(name,age){
            this.name = name;
            this.age = age;
        }
        User.prototype.show = function(){
            console.log(this.name,this.age)
        }


        function Admin(name,age){
            // 在子类中调用父类的初始值
            User.call(this,name,age);
        }
        let admin = new Admin('xiasnn',18);
        Admin.prototype.__proto__ = User.prototype;
        admin.show();


        function Member(...args){
            // 在子类中调用父类的初始值
            User.apply(this,args);
        }
        let member = new Member('xiaxia',19);
        Member.prototype.__proto__ = User.prototype;
        member.show();
    </script>
</body>
</html>